﻿using System.Diagnostics;

namespace Vicizlat.MultifloorCargoElevator
{
    internal class Utilities
    {
        public Stopwatch Stopwatch = new Stopwatch();
        internal int frame = -1;
        internal int second = -1;
        public bool Debug = false;
        public bool DebugAll = false;

        public void StopWatchReport(string message, float DebugTreshold = 0.01f)
        {
            Stopwatch.Stop();
            long ticks = Stopwatch.ElapsedTicks;
            double ns = 1000000000.0 * ticks / Stopwatch.Frequency;
            double ms = ns / 1000000.0;
            double s = ms / 1000;
            if (DebugTreshold <= -1) Logging.Instance.WriteLine(message + " - ms:" + (float)ms);
            else
            {
                if (ms >= DebugTreshold) Logging.Instance.WriteLine(message + " - ms:" + (float)ms);
            }
            Stopwatch.Reset();
        }

        public void Timing()
        {
            if (frame++ == 59) frame = 0;
            if (frame == 0 && second++ == 9) second = 0;
        }
    }
}